#include "macros.h"
#include "equations.h"
#include "math.h"

// prints the program header
void header() {
	printf("\n        CYLINDER PARAMETERS\n%s%s%s%s",
	"\n==================================================\n",
	"   PROG1018 : JR Lanteigne (JET 1)\n",
	"   FOR: Mr J. Murray\n",
	"==================================================\n" 
	"Circumference: \t2r * pi\n"
	"Surface Area: \t2r * pi + 2r * pi\n");
}

void _wait(unsigned int seconds) {
	time_t stop_exec = time(0) + seconds;
	while(time(0) <= stop_exec);
}

// get a fresh screen
void cls() {
	if(_IS_WINDOWS)
		system("cls");
	else
		system("clear"); // assume linux
	header();
}
int promptRadius(double *radius) {
	printf("\nEnter radius:\t ");
	static double a = 0;
	*radius = 0;
	if(scanf("%lf", &a) == 1) {
		*radius = abs(a);
		return 1;
	} else {
		return 0;
	}
}
int promptHeight(double *height) {
	printf("\nEnter height:\t ");
	static double a = 0;
	*height = 0;
	if(scanf("%lf", &a) == 1) {
		*height = abs(a);
		return 1;
	} else {
		return 0;
	}
}
void setCircum(double *circum, double radius) {
	*circum = 2 * radius * _PI;
}
void setTotalArea(double *area, double height, double radius) {
	*area = (2 * radius * _PI * height) + 2*(radius * radius * _PI);
}
void setCircleArea(double *circle, double radius) {
	*circle = radius * radius * _PI;
}